}
-
+void
+Diag(void *buf, size_t sz)
+{
+ unsigned char *cbuf = (unsigned char *) buf;
+ while (sz--) {
+ GPS_Diag("%02x ", *cbuf++);
+ }
+}
/* @func GPS_Write_Packet ***********************************************
**
int32 GPS_Write_Packet(int32 fd, GPS_PPacket packet)
{
size_t ret;
-
+
+ GPS_Diag("\nTx Data:");
+ Diag(&packet->dle, 3);
if((ret=GPS_Serial_Write(fd,(const void *)&packet->dle,(size_t)3)) == -1)
{
perror("write");
return 0;
}
+ Diag(packet->data, packet->bytes);
if((ret=GPS_Serial_Write(fd,(const void *)packet->data,(size_t)packet->bytes)) == -1)
{
perror("write");
}
+ Diag(&packet->chk, 3);
if((ret=GPS_Serial_Write(fd,(const void *)&packet->chk,(size_t)3)) == -1)
{
perror("write");
********************************************************************/
#include "gps.h"
#include <fcntl.h>
+#include <stdarg.h>
static int32 gps_endian_called=0;
static int32 GPS_Little=0;
return;
}
+void GPS_Diag(const char *fmt, ...)
+{
+ va_list argp;
+ va_start(argp, fmt);
+ if(gps_show_bytes) {
+ vfprintf(stdout, fmt, argp);
+ }
+ va_end(argp);
+ return;
+
+}
/* @func GPS_Enable_Diagnose ***********************************************
**